package com.hxc.web.controller.basicdata;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.basicdata.domain.TCommunityInfo;
import com.hxc.basicdata.service.ITCommunityInfoService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;

/**
 * 社区数据信息Controller
 * 
 * @author hxc
 * @date 2021-08-12
 */
@RestController
@RequestMapping("/basicdata/community")
public class TCommunityInfoController extends BaseController
{
    @Autowired
    private ITCommunityInfoService tCommunityInfoService;

    /**
     * 查询社区数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCommunityInfo tCommunityInfo)
    {
        startPage();
        List<TCommunityInfo> list = tCommunityInfoService.selectTCommunityInfoList(tCommunityInfo);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('basicdata:info:list')")
    @GetMapping("/communityList")
    public AjaxResult communityList(TCommunityInfo tCommunityInfo){
        List<TCommunityInfo> list = tCommunityInfoService.selectTCommunityInfoList(tCommunityInfo);
        return AjaxResult.success("success", list);
    }

    /**
     * 导出社区数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:export')")
    @Log(title = "社区数据信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TCommunityInfo tCommunityInfo)
    {
        List<TCommunityInfo> list = tCommunityInfoService.selectTCommunityInfoList(tCommunityInfo);
        ExcelUtil<TCommunityInfo> util = new ExcelUtil<TCommunityInfo>(TCommunityInfo.class);
        return util.exportExcel(list, "社区数据信息数据");
    }

    /**
     * 获取社区数据信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tCommunityInfoService.selectTCommunityInfoById(id));
    }

    /**
     * 新增社区数据信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:add')")
    @Log(title = "社区数据信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCommunityInfo tCommunityInfo)
    {
        return toAjax(tCommunityInfoService.insertTCommunityInfo(tCommunityInfo));
    }

    /**
     * 修改社区数据信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:edit')")
    @Log(title = "社区数据信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCommunityInfo tCommunityInfo)
    {
        return toAjax(tCommunityInfoService.updateTCommunityInfo(tCommunityInfo));
    }

    /**
     * 删除社区数据信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:info:remove')")
    @Log(title = "社区数据信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCommunityInfoService.deleteTCommunityInfoByIds(ids));
    }
}
